package com.rulestech.salespro.inventory;

import java.util.HashMap;
import java.util.Map;

public class ScoreBasedDiscount extends Discount {

	public enum Parameter{
		INVENTORY,SHELF_LIFE, HOLIDAY, SEASON, CUSTOMER_LOYATY;
	}
	
	/**
	 * This table hosts the weight for each discount parameter
	 */
	private  Map<Parameter, Double> weightMap = new HashMap <Parameter, Double>();
	
	
	/**
	 * Constructor
	 * @param productId primary key links to the Product
	 * @param useDefaultSetting flag indicating whether to use the default setting when processing the discount
	 */
	public ScoreBasedDiscount(long productId, boolean useDefaultSetting){
		super(productId, Discount.Type.SCORE_BASED, useDefaultSetting);
	}
		
	public void increaseRate (double score, Parameter parameter){
		setRate( getRate() + score * getWeight(parameter));
	}
	
	public double getWeight(Parameter parameter){
		return weightMap.get(parameter);
	}
	
	public void setWeight(Parameter parameter, double weight){
		weightMap.put(parameter, weight);
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
	
	
}
